import { App } from 'vue'
import * as Sentry from '@sentry/vue'
import { Integrations } from '@sentry/tracing'
import router from '@/router'

export function setupSentry(app: App) {
  // Sentry
  const isProduction = import.meta.env.MODE === 'production'
  Sentry.init({
    app,
    dsn: isProduction
      ? 'https://62d44ea0a3c84708802a001bc8d87338@sentry.madaomall.com/5'
      : 'https://ecd14eab588c43af94a788a74d43bba9@sentry.madaomall.com/6',
    integrations: [
      new Integrations.BrowserTracing({
        routingInstrumentation: Sentry.vueRouterInstrumentation(router),
        tracingOrigins: isProduction ? ['xth.itaored.com'] : ['localhost', 'testxth.itaored.com']
      })
    ],
    // Set tracesSampleRate to 1.0 to capture 100%
    // of transactions for performance monitoring.
    // We recommend adjusting this value in production
    tracesSampleRate: isProduction ? 0.5 : 1.0
  })
}
